-- update逻辑
local Action = class("Action")

function Action:ctor(updater, completed)
    self.completed = completed 
    self.updater = updater
end

function Action:start() 
    Time:addAction(self)
    self.startTime = CS.UnityEngine.Time.time
    self.elasped = 0
end 

function Action:update()
    if self.isDone then return end
    self.elasped = CS.UnityEngine.Time.time - self.startTime 
    if self.updater and self.updater(self) then
        self:Complete()
    end  
end 

function Action:complete()
    if self.completed then
        self.completed()
    end
    self.isDone = true
    self:Dispose()
end

function Action:dispose()
    self.updater = nil
    self.completed = nil
    Time:removeAction(self)
end

return M